package org.biubiu0002.baiblog.core.utils;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @Author: biubiu0002
 * @Date: 2022-05-19 1:24
 **/
public class ImageUtils {
    public static List<String> convertImagesUrl2UrlList(String imagesUrl){
        if (StringUtils.isBlank(imagesUrl)) {
            return Collections.emptyList();
        }
        return Arrays.asList(imagesUrl.split(","));
    }

    public static String convertImagesUrlList2Url(List<String> imagesUrlList){
        if (CollectionUtils.isEmpty(imagesUrlList)) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        for (String s : imagesUrlList) {
            sb.append(s).append(",");
        }
        sb.deleteCharAt(sb.length()-1);
        return sb.toString();
    }
}
